﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AutoFillCenter
{
    class GTalkAutoFill : AutoFill
    {
        public override bool Fill(String username, String password)
        {
            int id = DllLoader.FindWindow("Google Talk - Google Xmpp Client GUI Window", "Google Talk");
            int id2 = DllLoader.FindWindowEx(id, 0, "Main View", null);
            int id3 = DllLoader.FindWindowEx(id2, 0, null, null);
            int usernameCombo = DllLoader.FindWindowEx(id3, 0, "ComboBox", null);
            int passwordField = DllLoader.FindWindowEx(id3, 0, "Edit", null);
            int submitButton = DllLoader.FindWindowEx(id3, 0, "Button", "Sign in");
            
            DllLoader.SendMessage(usernameCombo,DllLoader.WM_SETTEXT,0,username);
            DllLoader.SendMessage(passwordField, DllLoader.WM_SETTEXT, 0, password);
            if (IS_AUTO_SUBMIT)
            {
                DllLoader.SendMessage(submitButton, DllLoader.BM_CLICK, 0, 0);
            }

            DllLoader.SetForegroundWindow(id);
            return true;
        }
    }
}
